var model = require("../DAO/model")
var express = require('express')
var multer = require("multer")
var userDao =require("../DAO/userDao")
var router = express.Router();

//权限过滤
router.all(function(req,res,next){
	if(req.session.userInfo !== null) {
		next()
	}else {
		res.send({
			rescode: "500",
			info: "调皮！"
		})
	}
})
//用户更改密码
router.post("/changePassword",userDao.changePwd)
//用户更改昵称
router.post("/changeName",userDao.changeName)


var storage = multer.diskStorage({
    //确定图片存储的位置
    destination: function (req, file, cb){
        cb(null, './static/img/avatar')
    },filename: function (req, file, cb){
        cb(null, Date.now()+file.originalname)
    }
});
var upload = multer({ storage:storage})
router.post("/changeAvatar",upload.single('file'),userDao.changeAvatar)

module.exports = router